home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / cips.c < prev    next >
Text File  |  1993-09-22  |  36KB  |  935 lines

  1.  
  2.    /***********************************************
  3.    *
  4.    *       file d:\cips\cips.c
  5.    *
  6.    *       Functions: This file contains
  7.    *          main
  8.    *          show_menu
  9.    *          show_image
  10.    *
  11.    *       Purpose:
  12.    *          This file contains the main calling
  13.    *          routine in the C Image Processing System.
  14.    *
  15.    *       External Calls:
  16.    *          numcvrt.c - get_integer
  17.    *          gin.c - get_image_name
  18.    *          rtiff.c - read_tiff_image
  19.    *          tiff.c - read_tiff_header
  20.    *          display.c - display_image
  21.    *                      display_menu_for_display_image
  22.    *          pi.c - print_image
  23.    *          ht.c - display_using_halftoning
  24.    *                 get_threshold_value
  25.    *          djet.c - print_graphics_image
  26.    *                   get_graphics_caption
  27.    *          hist.c - display_menu_for_histogram
  28.    *                   calculate_area_histogram
  29.    *                   print_histogram
  30.    *                   show_histogram
  31.    *          edge.c - detect_edges
  32.    *                   get_edge_options
  33.    *                   quick_edge
  34.    *          edge2.c - homogeneity
  35.    *                    difference_edge
  36.    *                    contrast_edge
  37.    *                    range
  38.    *                    variance
  39.    *          edge3.c - gaussian_edge
  40.    *                    enhance_edges
  41.    *          filter.c - filter_image
  42.    *                     median_filter
  43.    *                     high_pixel
  44.    *                     low_pixel
  45.    *                     get_filter_options
  46.    *          addsub.c - add_image_array
  47.    *                     subtract_image_array
  48.    *          cutp.c - cut_image_piece
  49.    *                   paste_image_piece
  50.    *                   check_cut_and_paste_limits
  51.    *          rotate.c - rotate_flip_image_array
  52.    *          scale.c - zoom_image_array
  53.    *          segment.c - get_segmentation_options
  54.    *                      get_threshold_options
  55.    *                      manual_threshold_segmentation
  56.    *                      peak_threshold_segmentation
  57.    *                      valley_threshold_segmentation
  58.    *                      adaptive_threshold_segmentation
  59.    *          boole.c - and_image
  60.    *                    or_image
  61.    *                    xor_image
  62.    *                    nand_image
  63.    *                    nor_image
  64.    *                    not_image
  65.    *          overlay.c - non_zero_overlay
  66.    *                      zero_overlay
  67.    *                      greater_overlay
  68.    *                      less_overlay
  69.    *                      average_overlay
  70.    *          ed.c - erosion
  71.    *                 dilation
  72.    *                 mask_erosion
  73.    *                 mask_dilation
  74.    *                 interior_outline
  75.    *                 exterior_outline
  76.    *                 copy_3_x_3
  77.    *                 opening
  78.    *                 closing
  79.    *                 get_shape_options
  80.    *          morph.c - thinning
  81.    *                    dilate_not_join
  82.    *                    special_opening
  83.    *                    special_closing
  84.    *                    edm
  85.    *                    mat
  86.    *          txtrsubs.c - sigma
  87.    *                       skewness
  88.    *                       amean
  89.    *                       adifference
  90.    *                       hurst
  91.    *                       compare
  92.    *                       get_texture_options
  93.    *
  94.    *
  95.    *       Modifications:
  96.    *          26 June 1990 - created
  97.    *
  98.    *************************************************/
  99.  
  100. #include "cips.h"
  101.  
  102.  
  103. short the_image[ROWS][COLS];
  104. short out_image[ROWS][COLS];
  105.  
  106. main()
  107. {
  108.  
  109.    char caption[80],
  110.         color_transform[80],
  111.         dir_name[80],
  112.         er_method[80],
  113.         low_high[80],
  114.         method[80],
  115.         monitor_type[80],
  116.         name[80],
  117.         name2[80],
  118.         name3[80],
  119.         rep[80],
  120.         title[80],
  121.         ts_method[80],
  122.         zoom_shrink[80];
  123.  
  124.    float percent = 0.5;
  125.  
  126.    int  color                = 99,
  127.         detect_threshold     = 1,
  128.         detect_type          = 1,
  129.         display_colors       = 16,
  130.             element              = 1,
  131.         filter_type          = 1,
  132.         high                 = 100,
  133.         horizontal           = 3,
  134.         i                    = 0,
  135.         ie                   = 1,
  136.         ie2                  = 1,
  137.         ie3                  = 1,
  138.         il                   = 1,
  139.         il2                  = 1,
  140.         il3                  = 1,
  141.         image_colors         = 256,
  142.         invert               = 0,
  143.         j                    = 0,
  144.         l                    = 0,
  145.         length               = 3,
  146.         le                   = COLS+1,
  147.         le2                  = COLS+1,
  148.         le3                  = COLS+1,
  149.             line                 = 1,
  150.         ll                   = ROWS+1,
  151.         ll2                  = ROWS+1,
  152.         ll3                  = ROWS+1,
  153.         not_finished         = 1,
  154.         number               = 1,
  155.         print                = 0,
  156.         response             = 99,
  157.         rotation_type        = 1,
  158.         scale                = 2,
  159.         show_hist            = 0,
  160.         size                 = 7,
  161.         threshold            = 128,
  162.         vertical             = 3,
  163.         width                = 3;
  164.  
  165.    long     mean_of_pixels;
  166.    unsigned long histogram[256];
  167.    short    diff  = 10,
  168.             erode =   3,
  169.             hi    = 255,
  170.             low   =   0,
  171.             min_area = 10,
  172.             max_area = 1000,
  173.             value = 200,
  174.             low_hi_filter[3][3];
  175.    struct   tiff_header_struct image_header;
  176.  
  177.  
  178.    my_clear_text_screen();
  179.  
  180.    strcpy(color_transform, "Straight mode");
  181.    strcpy(monitor_type, "VGA");
  182.    strcpy(low_high, "l");
  183.    strcpy(zoom_shrink, "z");
  184.    strcpy(method, "r");
  185.    strcpy(title, "");
  186.    strcpy(ts_method, "manual");
  187.    strcpy(er_method, "edge");
  188.  
  189.    strcpy(name,  "d:/pix/adam256.tif");
  190.    strcpy(name2, "d:/pix/output.tif");
  191.    strcpy(name3, "d:/pix/output.tif");
  192.    strcpy(dir_name, "d:/pix");
  193.  
  194.      while(not_finished){
  195.  
  196.         show_menu();
  197.  
  198.         get_integer(&response);
  199.  
  200.         switch (response){
  201.  
  202.         case 1:/* display image header */
  203.          get_image_name(name);
  204.          read_tiff_header(name, &image_header);
  205.          printf("\n\nCIPS> The image header is:");
  206.          printf("\n\t\twidth=%ld length=%ld  start=%ld  bits=%ld",
  207.               image_header.image_width,
  208.               image_header.image_length,
  209.               image_header.strip_offset,
  210.               image_header.bits_per_pixel);
  211.          printf("\nCIPS> Hit Enter to continue");
  212.          gets(rep);
  213.         break;
  214.  
  215.         case 2:/* display image numbers */
  216.          get_image_name(name);
  217.          get_parameters(&il, &ie, &ll, &le);
  218.          read_tiff_image(name, the_image, il, ie, ll, le);
  219.          show_image(the_image, il, ie);
  220.          break;
  221.  
  222.         case 3:   /* print image numbers */
  223.          get_image_name(name);
  224.          get_parameters(&il, &ie, &ll, &le);
  225.          read_tiff_image(name, the_image, il, ie, ll, le);
  226.          print_image(the_image, name, 1, 1, 1, 100, 18,
  227.                      il, ie);
  228.         break;
  229.  
  230.         case 4:   /* display image */
  231.          get_image_name(name);
  232.          read_tiff_header(name, &image_header);
  233.          get_parameters(&il, &ie, &ll, &le);
  234.          display_menu_for_display_image(&image_colors,
  235.                    &display_colors, &invert,
  236.                    color_transform, monitor_type,
  237.                    &show_hist);
  238.          printf("\nEnter title>");
  239.          gets(title);
  240.          display_image(name, the_image, il, ie,
  241.                    ll, le, &image_header, monitor_type,
  242.                    color_transform, invert,
  243.                    image_colors, display_colors,
  244.                    show_hist, title);
  245.         break;
  246.  
  247.         case 5:   /* display image using halftoning */
  248.          get_image_name(name);
  249.          read_tiff_header(name, &image_header);
  250.          get_par